<?php


namespace App\Http\Model\Common;


use App\Enum\EnumEnum;
use Illuminate\Support\Facades\DB;

class BusinessModel
{


    /**
     * 查询指定监管账户对应的业务线ID
     *
     * @param $pfsId
     *
     * @return array
     */
    public static function enumId($pfsId)
    {
        $enumId = DB::select("SELECT enum_id FROM `pfs_dw_ini` WHERE `id` IN ($pfsId) AND `is_del`=0 GROUP BY `enum_id` limit 100");
        if (empty($enumId)) {
            return [];
        }
        $enumIdArr = [];
        foreach ($enumId as $val) {
            $enumIdArr[] = $val->enum_id;
        }
        return array_unique($enumIdArr);
    }


    /**
     * 查询业务线列表
     *
     * @param $where
     * @param $enumId
     *
     * @return array
     */
    public static function search($where, $enumId)
    {
        if (empty($enumId)) {
            return [];
        }
        $enumId = implode(',', $enumId);
        return DB::select("SELECT `id`,`val`,`desc` FROM `enum` WHERE `id` IN ($enumId) AND classify=:classify AND `is_del`=0 AND (val LIKE :val OR `key` LIKE :key)", [
            'classify' => EnumEnum::LINE_OF_BUSINESS,
            'val'      => "%{$where}%",
            'key'      => "%{$where}%",
        ]);
    }

}





/**
 * BusinessModel.php
 *
 * 说明:
 *
 * 修改历史
 * ----------------------------------------
 * 2021/6/11 17:26:00   操作:创建
 **/
